package com.terrynoya.fight.stateMachine.controllers
{
	import com.terrynoya.fight.char.Character;
	import com.terrynoya.fight.char.Entity;
	import com.terrynoya.fight.stateMachine.StateController;
	import com.terrynoya.fight.stateMachine.StateMachine;
	import com.terrynoya.fight.stateMachine.controllers.attrParser.StateCtrlParserType;
	import com.terrynoya.geom.MVector2D;
	
	public class VelSet extends StateController
	{
		private var _x:Number = 0;
		
		private var _y:Number = 0;
		
		public function VelSet(name:String)
		{
			super(name);
		}
		
		public function get y():Number
		{
			return _y;
		}

		public function set y(value:Number):void
		{
			_y = value;
		}

		public function get x():Number
		{
			return _x;
		}

		public function set x(value:Number):void
		{
			_x = value;
		}
		
		override protected function initAttrConvertMap():void
		{
			this.attrConvertMap.put("x",StateCtrlParserType.Expression);
			this.attrConvertMap.put("y",StateCtrlParserType.Expression);
		}

		override public function run(character:Character):void
		{
			this._x = this.excuteExpression("x",character);
			this._y = this.excuteExpression("y",character);
//			trace(this._x,this._y);
			character.velocity = new MVector2D(this._x,this._y);
		}
	}
}